package com.hsmw.api.controller.pub;

import com.alibaba.fastjson.JSONObject;
import com.hsmw.api.vo.IDCardVericationVO;
import com.htn.common.core.base.DataResponse;
import com.htn.common.core.constant.CommonConstants;
import com.hsmw.domain.HsmwUser;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.faceid.v20180301.FaceidClient;
import com.tencentcloudapi.faceid.v20180301.models.IdCardVerificationRequest;
import com.tencentcloudapi.faceid.v20180301.models.IdCardVerificationResponse;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.HashMap;

public class IDCardVerificationUtils {


    public static IDCardVericationVO  iDCardVerification(IDCardVericationVO vo)  throws  TencentCloudSDKException{
            Credential cred = new Credential(CommonConstants.SECRET_ID, CommonConstants.SECRET_KEY);
            HttpProfile httpProfile = new HttpProfile();
            httpProfile.setEndpoint(CommonConstants.FACEID_ENDPOINT);
            ClientProfile clientProfile = new ClientProfile();
            clientProfile.setHttpProfile(httpProfile);

            FaceidClient client = new FaceidClient(cred, "", clientProfile);

            IdCardVerificationRequest req = new IdCardVerificationRequest();
            req.setIdCard(vo.getIDCard());
            req.setName(vo.getName());
            IdCardVerificationResponse resp = client.IdCardVerification(req);
            IDCardVericationVO vos = new IDCardVericationVO();
            vos.setDescription(resp.getDescription());
            vos.setCode(resp.getResult());
            return vos;
    }

}
